﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Entity;
namespace ETL.Business.Models
{
    public class ProjectCategoryModel
    {
        public project_categories ProjectCategories { get; set; }

        /// <summary>
        /// Constructor 
        /// </summary>
        /// <param name="projectCategories"></param>
        public ProjectCategoryModel(project_categories projectCategories)
        {
            this.ProjectCategories = projectCategories;
        }

        /// <summary>
        /// Get or set category id
        /// </summary>
        public byte? CategoryId
        {
            get { return this.ProjectCategories.c_category; }
        }

        /// <summary>
        /// Get or set category description
        /// </summary>
        public string Description { get { return this.ProjectCategories.c_description; }}

        /// <summary>
        /// Get or set category estimated hours
        /// </summary>
        public float? EstimatedHours { get { return this.ProjectCategories.c_est_hours; }}

        /// <summary>
        /// Get or set category estimated complete
        /// </summary>
        public float? EstimatedComplete { get { return this.ProjectCategories.c_est_complete; }}

        /// <summary>
        /// Get percent complete of category
        /// </summary>
        public string PercentComplete
        {
            get 
            { 
                if (this.ProjectCategories.c_est_complete.HasValue)
                {
                    return this.ProjectCategories.c_est_complete + " %";
                }
                else
                {
                    return null;
                }
            }
        }

        /// <summary>
        /// Displayed percent complete
        /// </summary>
        public string DisplayPercentComplete
        {
            get
            {
                if (this.ProjectCategories.c_est_hours.HasValue && this.ProjectCategories.c_est_complete.HasValue)
                {
                    var i = this.ProjectCategories.c_est_complete/this.ProjectCategories.c_est_hours;
                    return String.Format("{0:0}", i * 100) + " %";
                }
                else
                {
                    return string.Empty;
                }
            }
        }
        
    }
}
